<?php

class SmartController extends Controller
{
    public $jsfile = '';
	//列表广告
	public function actionIndex()
	{
        $keyword = CHtml::encode(trim($_GET['keyword']));
		if($keyword == ''){
			$keyword = '减肥瘦身';
		}
        $num = (int)trim($_GET['num']);
		if($num == 0){
			$num = 3;
		}
        $py = new Pinyin();
		$filename = $py->str2py($keyword);
		if(!$filename){
			$filename = date('Ymd',time());
		}
        $this->jsfile =$filename.'_out_indexlist.js';
        $this->renderPartial('index',array('kw'=>$keyword,'num'=>$num),false,true);
        Yii::app()->end();
	}
	//列表广告
	public function actionList()
	{
        $keyword = CHtml::encode(trim($_GET['keyword']));
		if($keyword == ''){
			$keyword = '减肥瘦身';
		}
        $num = (int)trim($_GET['num']);
		if($num == 0){
			$num = 3;
		}
        $py = new Pinyin();
		$filename = $py->str2py($keyword);
		if(!$filename){
			$filename = date('Ymd',time());
		}
        $this->jsfile =$filename.'_out_list.js';
        $this->renderPartial('list',array('kw'=>$keyword,'num'=>$num),false,true);
        Yii::app()->end();
	}
	//图书列表广告
	public function actionTushu()
	{
        $keyword = CHtml::encode(trim($_GET['keyword']));
		if($keyword == ''){
			$keyword = 'PHP';
		}
        $num = (int)trim($_GET['num']);
		if($num == 0){
			$num = 3;
		}
        $py = new Pinyin();
		$filename = $py->str2py($keyword);
		if(!$filename){
			$filename = date('Ymd',time());
		}
        $this->jsfile =$filename.'_out_tushulist.js';
        $this->renderPartial('list',array('kw'=>$keyword,'num'=>$num),false,true);
        Yii::app()->end();
	}
	//Big list 大列表广告
	public function actionBlist()
	{
        $keyword = CHtml::encode(trim($_GET['keyword']));
		if($keyword == ''){
			$keyword = '减肥瘦身';
		}
        $num = (int)trim($_GET['num']);
		if($num == 0){
			$num = 3;
		}
        $py = new Pinyin();
		$filename = $py->str2py($keyword);
		if(!$filename){
			$filename = date('Ymd',time());
		}
        $this->jsfile =$filename.'_out_blist4.js';
        $this->renderPartial('blist',array('kw'=>$keyword,'num'=>$num),false,true);
        Yii::app()->end();
	}
	//Big list 大列表广告
	public function actionBetalist()
	{
        $keyword = CHtml::encode(trim($_GET['keyword']));
		if($keyword == ''){
			$keyword = '减肥瘦身';
		}
        $num = (int)trim($_GET['num']);
		if($num == 0){
			$num = 3;
		}
        $py = new Pinyin();
		$filename = $py->str2py($keyword);
		if(!$filename){
			$filename = date('Ymd',time());
		}
        $this->jsfile =$filename.'_out_betalist.js';
        $this->renderPartial('betalist',array('kw'=>$keyword,'num'=>$num),false,true);
        Yii::app()->end();
	}
	//Scroll广告
	public function actionScroll()
	{	
		$keyword = CHtml::encode(trim($_GET['keyword']));
		if($keyword == ''){
			$keyword = '减肥 瘦身';
		}
        $py = new Pinyin();
        $filename = $py->str2py($keyword);
		if(!$filename){
			$filename = date('Ymd',time());
		}
        $this->jsfile =$filename.'_out_scroll.js';
        $this->renderPartial('scroll',array('kw'=>$keyword),false,true);
        Yii::app()->end();
	}
	//24beta Scroll广告
	public function actionScrollb()
	{	
		$keyword = CHtml::encode(trim($_GET['keyword']));
		if($keyword == ''){
			$keyword = '减肥 瘦身';
		}
        $py = new Pinyin();
        $filename = $py->str2py($keyword);
		if(!$filename){
			$filename = date('Ymd',time());
		}
        $this->jsfile =$filename.'_out_scrollbe.js';
        $this->renderPartial('scrollb',array('kw'=>$keyword),false,true);
        Yii::app()->end();
	}
	//Slider广告
	public function actionSlider()
	{	
		$keyword = CHtml::encode(trim($_GET['keyword']));
		if($keyword == ''){
			$keyword = '减肥 瘦身';
		}
        $py = new Pinyin();
		$thisid = $py->str2py($keyword);
		if(!$thisid){
			$thisid = date('Ymd',time());
		}
        $this->jsfile = $thisid.'_out_slider.js';
        $this->renderPartial('slider',array('kw'=>$keyword,'id'=>$thisid,'file'=>$this->jsfile),false,true);
        Yii::app()->end();
	}
	//24beta Slider广告
	public function actionSliderb()
	{	
		$keyword = CHtml::encode(trim($_GET['keyword']));
		if($keyword == ''){
			$keyword = '美容 瘦身';
		}
        $py = new Pinyin();
		$thisid = $py->str2py($keyword);
		if(!$thisid){
			$thisid = date('Ymd',time());
		}
        $this->jsfile = $thisid.'_out_sliderb.js';
        $this->renderPartial('sliderb',array('kw'=>$keyword,'id'=>$thisid,'file'=>$this->jsfile),false,true);
        Yii::app()->end();
	}
}